import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

export const allRouter = [
    {
        path: '/',
        redirect: '/screen',// 当访问根路径时重定向到登录页
        hidden: true
    },

    {
        path: '/screen',
        name: 'Screen',
        hidden: true,
        component: () => import('@/views/screen/index'),
    },
    {
        path: '/video',
        name: 'Video',
        hidden: true,
        component: () => import('@/views/video/index'),
    }
]

const router = new VueRouter({
    mode: 'hash', // 使用 hash 模式
    routes: allRouter
});

router.beforeEach((to, from, next) => {
  // 必须调用 next()，否则跳转被拦截
  if (to.name === 'Video') {
    next(); // 允许跳转
  } else {
    next(); // 其他路由也需调用
  }
});

export default router;